package it.lorenz.server.fk.business.mail;

import it.lorenz.server.fk.business.AbstractDTO;
import java.util.Arrays;
import java.util.Collection;

public class MailDTO extends AbstractDTO {

    private static final long serialVersionUID = 3286767998728602127L;
    private String from;
    private String bounceEmail;
    private Collection<String> tos;
    private Collection<String> ccs;
    private Collection<String> bccs;
    private String subject;
    private String message;
    private Boolean htmlFormatted;
    private Collection<Attachment> attachments;

    public void addTo(String... email) {
        if (tos == null) {
            tos = Arrays.asList(email);
        } else {
            add(tos, email);
        }
    }

    public void addCc(String email) {
        if (ccs == null) {
            ccs = Arrays.asList(email);
        } else {
            add(ccs, email);
        }
    }

    public void addBcc(String email) {
        if (bccs == null) {
            bccs = Arrays.asList(email);
        } else {
            add(bccs, email);
        }
    }

    public void addAttachment(Attachment attachment) {
        if (attachments == null) {
            attachments = Arrays.asList(attachment);
        } else {
            add(attachments, attachment);
        }
    }

    private <T> void add(Collection<T> collection, T... objects) {
        for (T object : objects) {
            collection.add(object);
        }
    }

    String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    String getBounceEmail() {
        return bounceEmail;
    }

    public void setBounceEmail(String bounceEmail) {
        this.bounceEmail = bounceEmail;
    }

    Collection<String> getTos() {
        return tos;
    }

    Collection<String> getCcs() {
        return ccs;
    }

    Collection<String> getBccs() {
        return bccs;
    }

    String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    String getMessage() {
        return message;
    }

    public void setMessage(String message, Boolean htmlFormatted) {
        this.message = message;
        this.htmlFormatted = htmlFormatted;
    }

    Boolean isHtmlFormatted() {
        return htmlFormatted;
    }

    Collection<Attachment> getAttachments() {
        return attachments;
    }
}
